// 不是静态方法，需要定义在原型对象身上
const MyPromise = require("./MyPromise");

class MyPromise {
  finally(callback) {
    return this.then(
      (value) => {
        // callback();
        // return value;
        return MyPromise.resolve(callback()).then(() => value);
      },
      (reason) => {
        // callback();
        // throw reason;
        return MyPromise.resolve(callback()).then(() => throw reason);
      }
    );
  }
}
